<template>
	<view>
		<!-- 自定义导航栏 -->
		<view class="navBarBox">
			<!-- 状态栏占位 -->
			<view class="statusBar" :style="{ paddingTop: statusBarHeight + 'px' }"></view>
			<!-- 真正的导航栏内容 -->
			<view class="navBar">
				<view class="goback">
					<view @click="goBack" class="goicon" style="background:url(../../static/goback.png);background-size:contain;background-repeat: no-repeat;">
					</view>
				</view>
				<view class="title">选择老师</view>
				<view class="right">

				</view>
			</view>
		</view>
		<!-- 页面内容 -->
		<view class="content">
			<view class="contentlist"  v-for="(item,index) in getTeachers" :key='item.id'>
				<view class="contentlistcont">
					<image src="../../static/img/register/1head.png" mode=""></image>
					<view class="teachermesg">
						<view class="teachername">
							<text>{{item.teacherName}}</text>
							<text>老师</text>
						</view>
						<view class="">
							<checkbox-group @change="checkboxChange">
								<label>
									<checkbox :value="item.id" style="transform:scale(0.7)" />
								</label>
							</checkbox-group>
						</view>

					</view>

				</view>
			</view>



		</view>
		<!-- 底部提交按钮 -->
		<button class="setclssbt" @click="setTeacher()">确认选择</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				getOrgId: 0, //当前申报课程的机构ids
				getCourseId: 0, //当前课程的id
				getTeachers: [], //存放当前申报课程的机构下的老师
				teacherId: 0, //老师的
				getall: [], //课程的全部
				// 状态栏高度
				statusBarHeight: 0,
				// 导航栏高度
				navBarHeight: 82 + 11,
			};
		},
		props: {

		},
		onLoad: function(option) {
			const item = JSON.parse(decodeURIComponent(option.item));
			this.getOrgId = item.applyOrgId; //获取申报课程的机构的id
			this.getCourseId = item.id //获取申报课程的id
			// this.getall=item//全部
			this.getTeacher()
			// console.log(item,'全部')
		},
		onShow: function() {
			// console.log(item,'当前课程的全部信息')

			// console.log(this.getOrgId, '当前课程的申报课程的机构id')

		},
		//第一次加载时调用
		created() {
			//获取手机状态栏高度
			this.statusBarHeight = uni.getSystemInfoSync()['statusBarHeight'];
		},
		methods: {
			goBack() {
				// 此处是写返回页面的方法、
				uni.navigateBack({
					delta: 1 //返回只上一级页面
				});
			},
			checkboxChange: function(e) {
				this.teacherId = e.detail.value[0]
			},


			getTeacher: function() {
				this.$myRequest({
					url: '/admin/teacher/finds/' + this.getOrgId,
					method: 'get',

					success: (res) => {
						// console.log(res,'得到的数据')
						this.getTeachers = res.data.data;

						// console.log(this.getTeachers, '纯老师')
					},
					fail: (err) => {
						console.log(err)
						console.log('获取数据中')

					}
				})
			},
			setTeacher: function() {
				this.$myRequest({
					url: '/admin/course/open',
					data: {
						applyCourseId: this.getCourseId,
						teacherId: this.teacherId
					},
					success: (res) => {

						// uni.showModal({
						//     title: '老师设置成功',
						//     duration: 4000,
						//     success: function (res) {
						//         uni.navigateTo({
						//         	url: '../coursemanag/courseInviteList'
						//         })
						//     }
						// })
						uni.showLoading({
							title: '老师设置成功'
						});

						setTimeout(function() {
							uni.hideLoading();
						}, 2000);
						



					},
					fail: (err) => {
						console.log(err)
						console.log('获取数据中')
					}
				})
			}
		}
	}
</script>

<style>
	.navBarBox {}

	.navBarBox .statusBar {}

	.navBarBox .navBar {
		padding: 3rpx 50rpx;
		padding-bottom: 8rpx;
		display: flex;
		justify-content: space-between;

		line-height: 93rpx;
		font-size: 40rpx;
	}

	.goback {
		flex: 1;
		height: 100%;
	}

	.goicon {
		width: 30rpx;
		height: 30rpx;
		background-color: #00BEA9;
		margin-top: 30rpx;
	}

	.title {
		flex: 1;
		height: 100%;

	}

	.right {
		flex: 1;
	}

	.content {
		width: 100%;
		height: 100%;
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		background-color: #f4f4f4;
	}

	.contentlist {
		width: 700rpx;
		height: 200rpx;
		background-color: #FFFFFF;
		border-radius: 10rpx;
		margin-top: 20rpx;
		display: flex;
		justify-content: space-around;
		align-items: center;
	}

	.contentlistcont {
		width: 620rpx;
		height: 130rpx;
		display: flex;
		justify-content: space-around;
		background-color: ;

	}

	.contentlistcont image {
		width: 130rpx;
		height: 130rpx;
	}

	.teachermesg {
		width: 490rpx;
		height: 100%;

		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.teachername {
		height: 40rpx;
		display: flex;
		justify-content: flex-start;
		margin-left: 20rpx;
	}

	/* 重写 checkbox 样式 */
	/* 未选中的 背景样式 */
	checkbox .wx-checkbox-input {
		border-radius: 50%;
		/* 圆角 */
		width: 46rpx;
		/* 背景的宽 */
		height: 46rpx;
		/* 背景的高 */
	}

	/* 选中后的 背景样式*/
	checkbox .wx-checkbox-input.wx-checkbox-input-checked {
		background: #46f1de;
	}

	/* 选中后的 对勾样式 */
	checkbox .wx-checkbox-input.wx-checkbox-input-checked::before {
		border-radius: 50%;
		/* 圆角 */
		width: 40rpx;
		/* 选中后对勾大小，不要超过背景的尺寸 */
		height: 40rpx;
		/* 选中后对勾大小，不要超过背景的尺寸 */
		line-height: 40rpx;
		text-align: center;
		font-size: 30rpx;
		/* 对勾大小 30rpx */
		color: #fff;
		/* 对勾颜色 白色 */
		background: transparent;
		transform: translate(-50%, -50%) scale(1);
		-webkit-transform: translate(-50%, -50%) scale(1);
	}

	.setclssbt {
		width: 225rpx;
		height: 70rpx;
		border-radius: 10rpx;
		font-size: 26rpx;
		text-align: center;
		line-height: 70rpx;
		margin-top: 60rpx;
		color: #FFFFFF;
		border: none;
		background-color: #2db3fe;
		box-shadow: 5rpx 5rpx 10rpx 2rpx #2db3fe;
	}
</style>
